home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8362 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: ix.netcom.com!netnews
  2. From: Norman Bullen <nbullen@ix.netcom.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to make this code portable?
  5. Date: Sun, 03 Mar 1996 09:44:41 -0800
  6. Organization: Black Cat Associates
  7. Message-ID: <3139DA89.3CA1@ix.netcom.com>
  8. References: <4h8k9j$78r@habs.ee.ubc.ca> <4hbsaa$fmu@news.acns.nwu.edu>
  9. NNTP-Posting-Host: ple-ca9-22.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-NETCOM-Date: Sun Mar 03  9:53:54 AM PST 1996
  14. X-Mailer: Mozilla 2.0 (Win16; I)
  15.  
  16. Usman Muzaffar wrote:
  17. > In article <4h8k9j$78r@habs.ee.ubc.ca>, Ellen Ho <ellenh@ee.ubc.ca> wrote:
  18. > >I am writing a program that I want to compile and run on both a Sun
  19. > >Sparcstation and a PC running OS/2 Warp.  On the Sun, I compile the .c
  20. > >files with gcc.  On the PC, I am using Visual Age.
  21. > >
  22. > >The program acceptes a list of filenames as command line
  23. > >arguments and does some processing with the list of files.
  24. > >On the Sun, I specify
  25. > >
  26. > >        program *.txt
  27. > >
  28. > >and the shell will expand the wildcard into the names of all .txt
  29. > >files in the current working directory.  So with a for loop in
  30. > >my C program I can go through each file and process the data.
  31. > >
  32. > >However, on the PC, "*.txt" is passed into my program as
  33. > >command line argument as is.  This means that I may have to
  34. > >put in extra operating system dependent logic to expand the wildcard
  35. > >inside my program.
  36. > >
  37. > >Are there other ways to handle this?
  38. > I think the best way to approach this is to write a dos batch file
  39. > that reads all .txt files and feeds them to your code. Or, if that's
  40. > not easy, just write a couple of lines of which do it and call that
  41. > as a frontend. Your main code stays untouched. 
  42. The Borland C compilers include a library routine that can be invoked as 
  43. part of the start-up module that expands *.txt into a list of filename so 
  44. that it appears to your code just as it would on Unix. Look for 
  45. "wildargs" in the documentation.
  46.